package WordFrequent;

import java.util.List;
import java.util.Map;

public class fourstep {


    public static List<Map.Entry<String,Integer>> deal(String book, String v) {
        List<Map.Entry<String,Integer>> list = Onestep.sort(book);
//        System.out.println(v);
//        System.out.println("==========");
        //创建一个V数组按逗号分割并存储v表
        String[] V = v.split(",");
        for (int i = 0 ;i<list.size();i++){
            //System.out.println(list.get(i).getKey()+"===="+list.get(i).getValue());
            for (int j = 0 ; j< V.length ; j++){
               //设置一个零时数组存储数据。
                String[] tmp = V[j].split(" ");
                if (list.get(i).getKey().charAt(0) != V[j].charAt(0)){
                    continue;
                }else{
                    for (int k = 1; k <tmp.length;k++){
                        if (tmp[k].equals(list.get(i).getKey())){
                           int times = list.get(i).getValue();
                           for (int z = 0; z<list.size();z++ ) {
                               if (list.get(z).getKey().equals(tmp[0])){
                                   int intmp =list.get(z).getValue();
                                   list.get(z).setValue(intmp+times);
                                   list.remove(i);
                                   i--;
                                   break;
                               }


                               }
                           }
                    }
                }

            }


            }

                return  list;
        }
    }
